package com.cn.bulu.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.cn.bulu.service.IndentService;

@Controller
@RequestMapping("/indents")
public class IndentsController{
	
	@Resource
	private IndentService indentService;
	
	@RequestMapping("showIndents")
	public String showIndents(HttpServletRequest request,Integer page){
		if(page==null)
			page=1;
		request.setAttribute("indents", indentService.showIndents(page));//当前页码下的所有订单
		request.setAttribute("currentPage", page);//当前页码
		request.setAttribute("totalPages", indentService.getTotalPages());//分页总数
		return "/jsp/indents_list";
	}
	
	@RequestMapping("showGoods")
	public String showGoods(HttpServletRequest request, Integer indentId){
		List<Map<String,Object>> list=new ArrayList<>();
		
		if(indentId != null){
			List<Map<String,Object>> goods=indentService.showGoods( indentId);
			if(goods!=null && goods.size()>=0)
			list.addAll(goods);
		}
		System.out.println("=======================");
		System.out.println(list);
		request.setAttribute("goods", list);
		return "/jsp/goods_list";
	}

}
